﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGeExternalBoundedSurface : OdGeSurface
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGeExternalBoundedSurface(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGeExternalBoundedSurface_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGeExternalBoundedSurface obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGeExternalBoundedSurface()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGeExternalBoundedSurface(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public void getContours(out int numContours, out OdGeCurveBoundary[] contours)
		{
            IntPtr ptr = IntPtr.Zero;
			GlobalsPINVOKE.OdGeExternalBoundedSurface_getContours(this.swigCPtr, out numContours, out ptr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			if (numContours == 0)
			{
				contours = null;
				return;
			}
			contours = new OdGeCurveBoundary[numContours];
			for (int i = 0; i < numContours; i++)
			{
				contours[i] = new OdGeCurveBoundary(Marshal.ReadIntPtr(ptr, i * Marshal.SizeOf(Marshal.SizeOf(typeof(IntPtr)))), false);
			}
		}

		public OdGeExternalBoundedSurface() : this(GlobalsPINVOKE.new_OdGeExternalBoundedSurface__SWIG_0(), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeExternalBoundedSurface(IntPtr pSurfaceDef, OdGe.ExternalEntityKind surfaceKind, bool makeCopy) : this(GlobalsPINVOKE.new_OdGeExternalBoundedSurface__SWIG_1(pSurfaceDef, (int)surfaceKind, makeCopy), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeExternalBoundedSurface(IntPtr pSurfaceDef, OdGe.ExternalEntityKind surfaceKind) : this(GlobalsPINVOKE.new_OdGeExternalBoundedSurface__SWIG_2(pSurfaceDef, (int)surfaceKind), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGeExternalBoundedSurface(OdGeExternalBoundedSurface source) : this(GlobalsPINVOKE.new_OdGeExternalBoundedSurface__SWIG_3(OdGeExternalBoundedSurface.getCPtr(source)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGe.ExternalEntityKind externalSurfaceKind()
		{
			OdGe.ExternalEntityKind result = (OdGe.ExternalEntityKind)GlobalsPINVOKE.OdGeExternalBoundedSurface_externalSurfaceKind(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isDefined()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isDefined(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void getExternalSurface(out IntPtr pSurfaceDef)
		{
			GlobalsPINVOKE.OdGeExternalBoundedSurface_getExternalSurface(this.swigCPtr, out pSurfaceDef);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getBaseSurface(OdGeSurface pSurfaceDef)
		{
			GlobalsPINVOKE.OdGeExternalBoundedSurface_getBaseSurface__SWIG_0(this.swigCPtr, pSurfaceDef);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public void getBaseSurface(OdGeExternalSurface unboundedSurfaceDef)
		{
			GlobalsPINVOKE.OdGeExternalBoundedSurface_getBaseSurface__SWIG_1(this.swigCPtr, OdGeExternalSurface.getCPtr(unboundedSurfaceDef));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isPlane()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isPlane(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isSphere()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isSphere(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isCylinder()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isCylinder(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isCone()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isCone(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEllipCylinder()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isEllipCylinder(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isEllipCone()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isEllipCone(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isTorus()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isTorus(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isNurbs()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isNurbs(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isExternalSurface()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isExternalSurface(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public int numContours()
		{
			int result = GlobalsPINVOKE.OdGeExternalBoundedSurface_numContours(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExternalBoundedSurface set(IntPtr pSurfaceDef, OdGe.ExternalEntityKind surfaceKind, bool makeCopy)
		{
			OdGeExternalBoundedSurface result = new OdGeExternalBoundedSurface(GlobalsPINVOKE.OdGeExternalBoundedSurface_set__SWIG_0(this.swigCPtr, pSurfaceDef, (int)surfaceKind, makeCopy), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExternalBoundedSurface set(IntPtr pSurfaceDef, OdGe.ExternalEntityKind surfaceKind)
		{
			OdGeExternalBoundedSurface result = new OdGeExternalBoundedSurface(GlobalsPINVOKE.OdGeExternalBoundedSurface_set__SWIG_1(this.swigCPtr, pSurfaceDef, (int)surfaceKind), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isOwnerOfSurface()
		{
			bool result = GlobalsPINVOKE.OdGeExternalBoundedSurface_isOwnerOfSurface(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExternalBoundedSurface setToOwnSurface()
		{
			OdGeExternalBoundedSurface result = new OdGeExternalBoundedSurface(GlobalsPINVOKE.OdGeExternalBoundedSurface_setToOwnSurface(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGeExternalBoundedSurface Assign(OdGeExternalBoundedSurface extBoundSurf)
		{
			OdGeExternalBoundedSurface result = new OdGeExternalBoundedSurface(GlobalsPINVOKE.OdGeExternalBoundedSurface_Assign(this.swigCPtr, OdGeExternalBoundedSurface.getCPtr(extBoundSurf)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
